﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StoryTeller.Domain.Repository;
namespace StoryTeller.Domain
{
    public class Story : BaseDomain
    {
        public Story()
        {
            this.CreationDate = DateTime.Now;
            this.LastUpdate = DateTime.Now;
        }

        public Group Group { get; set; }

        public bool IsPublic { get; set; }

        public string Title { get; set; }

        public string Description { get; set; }

        public ECategory Category { get; set; }

        public ICollection<Chapter> Chapters { get; set; }       

        public override bool Validate()
        {
            ValidationMessages = new List<string>();

            if (string.IsNullOrEmpty(this.Title))
            {
                ValidationMessages.Add(Resources.Validation.ValidationMessages.StoryTitleMessage);
            }

            if (string.IsNullOrEmpty(this.Description))
            {
                ValidationMessages.Add(Resources.Validation.ValidationMessages.StoryDescriptionMessage);
            }

            if (Category == ECategory.none)
            {
                ValidationMessages.Add(Resources.Validation.ValidationMessages.StoryCategoryMessage);
            }

            return ValidationMessages.Count > 0;
        }
    }
}
